//
// Created by cyrus on 1/28/24.
//

#include "runtime_stub.h"

namespace bts {
std::shared_ptr<RuntimeStub> RuntimeStub::instance_;

RuntimeStub *RuntimeStub::GetInstance() {
  if (instance_ == nullptr) {
    instance_ = std::make_shared<RuntimeStub>();
  }
  return instance_.get();
}

Status RuntimeStub::rtMalloc(void **ptr, size_t size) {
  *ptr = new uint8_t[size];
  return Status::SUCCESS;
}

Status RuntimeStub::rtFree(void *ptr) {
  if (ptr != nullptr) {
    delete[](uint8_t *) ptr;
  }
  return Status::SUCCESS;
}
}  // namespace bts